
/**
* @Title: ThreadInterrupt.java
* @Package com.leetone
* @Description: 【】
* @date 2018年8月28日 上午10:55:36
* @version V1.0
* @Company: 上海未泰信息技术有限公司
* @author:[谭磊][leetone123@163.com]
*/

package com.leetone;


/**
* @ClassName: ThreadInterrupt
* @Description: 【中断线程，原来的stop废弃不用】
* @date 2018年8月28日 上午10:55:36
* @Company: 上海未泰信息技术有限公司
* @author:[谭磊][leetone123@163.com]
*/

public class ThreadInterrupt implements Runnable{
	@Override
	public void run() {

		boolean stop = false;
		while(!stop) {
			System.out.println("My thread is running...");
			try {
				Thread.sleep(3L);
			} catch (InterruptedException e) {
				e.printStackTrace();
				break;
			}
		}
		System.out.println("My thread exiting under request...");
	}
	
	public static void main(String[] args) throws InterruptedException {
		Thread thread = new Thread(new ThreadInterrupt(),"InterruptThread");
		System.out.println("Start");
		thread.start();
		Thread.sleep(3000);
		System.out.println("interrupt");
		thread.interrupt();
		System.out.println("是否中断：\t"+thread.isInterrupted());
		Thread.sleep(3000);
		System.out.println("停止应用。。。");
	}
}
